﻿@page
@using LearnRazorPage.Models
@using LearnRazorPage.Services

@inject IDepartmentService deparmentService

<div class="row">
    <div class="col-md-10 offset-md-2">
        <table class="table">
            <tr>
                <th>Name</th>
                <th>Location</th>
                <th>Employee Count</th>
                <th>操作</th>
            </tr>
            @Html.DisplayFor(x=>x.Departments)
        </table>
    </div>
</div>


<div class="row">
    <div class="col-md-4 offset-md-2">
        <a asp-page="Department/AddDepartment">Add</a>
    </div>
    <div class="col-md-4">
        @await Component.InvokeAsync("CompanySummary",new {title = "部门列表页的汇总"})
        <vc:company-summary title="部门列表页的汇总2"></vc:company-summary>
    </div>
</div>

@functions
{
    public IEnumerable<Models.Department> Departments { get; set; }

    //Get请求过来后走这个方法
    public async Task OnGetAsync()
    {
        
        Departments = await deparmentService.GetAll();
    }
}
